<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/9/19
 * Time: 15:03
 */


function my_filter($arr,$callback=null){
    $tmp = [];
    foreach($arr as $k=>$v){
        if ($callback==null){
            if ($v){
                $tmp[$k] = $v;
            }
        }else {
           if($callback($v)){
               $tmp[$k] = $v;
           }
        }

    }
    return $tmp;
}
$arr = range(0,10);
$brr = my_filter($arr);
var_dump($brr);
$brr = my_filter($arr,function($v){
    if($v%2==0){
        return true;
    } else {
        return false;
    }
});
var_dump($brr);